import { View } from "../../../mvc/core/View";
import { LayerManager } from "../../manager/LayerManager";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { Language } from "../../../../extend/language/Language";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { GButton } from "../../../../com/mui/controls/GButton";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
//class NumberKeyboardSprite
    
    export  class NumberKeyboardSprite extends View
    {
        constructor()
        {
            super();
            layer = LayerManager.windowLayer;
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc5=null;
            var loc1=ObjCreate.createBg(0, 0, 175, 210, this, ImagesConst.WindowCenterA);
            var loc2=ObjCreate.createBg(5, 5, 165, 200, this, ImagesConst.WindowCenterB);
            var loc3=ObjCreate.createTextField(Language.getString(35524), 60, 10, 80, 20, this, GlobalStyle.textFormat1);
            loc3.filters = [];
            var loc4;
            (loc4 = ObjCreate.createGButton("", 150, 5, 19, 19, this, "CloseButton")).addEventListener(flash.events.MouseEvent.CLICK, this.onCloseBtnClickHandler);
            var loc6=25;
            var loc7=35;
            var loc8=0;
            while (loc8 < 12) 
            {
                loc5 = ObjCreate.createGButton("", loc6, loc7, 34, 34, this, "numberKeyButton");
                if ((loc8 + 1) % 3 != 0) 
                {
                    loc6 = loc6 + loc5.width + 12;
                }
                else 
                {
                    loc6 = 25;
                    loc7 = 35 + (loc5.height + 8) * (loc8 + 1) / 3;
                }
                if (loc8 < 9) 
                {
                    loc5.label = (loc8 + 1).toString();
                }
                else if (loc8 != 9) 
                {
                    if (loc8 != 10) 
                    {
                        if (loc8 == 11) 
                        {
                            loc5.label = "C";
                        }
                    }
                    else 
                    {
                        loc5.label = "0";
                    }
                }
                else 
                {
                    loc5.label = "←";
                }
                loc5.addEventListener(flash.events.MouseEvent.CLICK, this.onNumBtnClickHandler);
                ++loc8;
            }
            return;
        }

        /* internal  */onNumBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            var loc1=arg1.target as GButton;
            Dispatcher.dispatchEvent(new DataEvent(EventName.LockNumberKeyboardChange, loc1.label));
            return;
        }

        /* internal  */onCloseBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            this.hide();
            return;
        }
    }
